/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-21
 * Time: 16:25
 */
//终止线程
public class Demo7 {
    //内部类访问外部类的成员

    public static void main(String[] args) throws InterruptedException {
        boolean  isQuit=false;
        boolean finalIsQuit = isQuit;
        Thread t=new Thread(() ->{
           while(!finalIsQuit){
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });
        t.start();
        //主线程在这里执行一些逻辑
        Thread.sleep(4000);
        //当主线程执行一些逻辑之后，我想要关闭别的线程

        //修改标志位
        isQuit=true;
        System.out.println("线程t终止");


    }
}
